#ifndef RICHTEXTEDIT_H
#define RICHTEXTEDIT_H

#include <QTextEdit>
#include <QToolBar>
#include <QTextList>
#include <QFontComboBox>
#include <QComboBox>
#include <QColorDialog>
#include <QMenu>
#include <QAction>
#include <QActionGroup>
#include <QContextMenuEvent>
#include <QTimer>

class RichTextEdit : public QTextEdit
{
	Q_OBJECT

	public:
		RichTextEdit(QWidget * parent = 0);
		~RichTextEdit();

	public slots:
		void changeAlignment(QAction *);
		void setBold(bool);
		void setColor();
		void setFontSize(const QString &);
		void setList(bool);

	protected:
		void contextMenuEvent(QContextMenuEvent *e);

	private:
		QToolBar *toolbar;
		QFontComboBox *fontBox;
		QComboBox *sizeBox;
		QAction *colorPickerAction;
		QAction *boldAction, *italicAction, *underlineAction;
		QAction *leftAlignAction, *centerAlignAction, *rightAlignAction, *justifyAction;
		QActionGroup *alignGroup;
		QTimer *timer;

	private slots:
		void updateCharFormat(const QTextCharFormat &);
		void updateBlockFormat();

	signals:
		void save();
};

#endif // RICHTEXTEDIT_H
